//
//  RootViewController.m
//  下拉菜单
//
//  Created by dllo on 15/12/9.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootViewController.h"
#import "DOPDropDownMenu.h"

@interface RootViewController ()<DOPDropDownMenuDataSource, DOPDropDownMenuDelegate>

@property (nonatomic, retain) NSArray *classifys;
@property (nonatomic, retain) NSArray *area;
@property (nonatomic, retain) NSArray *sorts;
@property (nonatomic, retain) NSArray *hotel;

@end

@implementation RootViewController

- (void)dealloc
{
    [_classifys release];
    [_area release];
    [_sorts release];
    [_hotel release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.classifys = @[@"美食",@"今日新单",@"电影",@"酒店"];
    self.hotel = @[@"经济酒店",@"商务酒店",@"连锁酒店",@"度假酒店",@"公寓酒店"];
    self.area = @[@"全城",@"芙蓉区",@"雨花区",@"天心区",@"开福区",@"岳麓区"];
    self.sorts = @[@"默认排序",@"离我最近",@"好评优先",@"人气优先",@"最新发布"];
    
    DOPDropDownMenu *menu = [[DOPDropDownMenu alloc] initWithOrigin:CGPointMake(0, 60) andHeight:44];
    menu.delegate = self;
    menu.dataSource = self;
    [self.view addSubview:menu];
    [menu release];
    
}

- (NSInteger)menu:(DOPDropDownMenu *)menu numberOfItemsInRow:(NSInteger)row column:(NSInteger)column
{
    if (0 == column) {
        if (3 == row) {
            return self.hotel.count;
        }
    }
    return 0;
}

- (NSString *)menu:(DOPDropDownMenu *)menu titleForItemsInRowAtIndexPath:(DOPIndexPath *)indexPath
{
    if (0 == indexPath.column) {
        if (3 == indexPath.row) {
            return self.hotel[indexPath.item];
        }
    }
    return nil;
}

- (NSInteger)numberOfColumnsInMenu:(DOPDropDownMenu *)menu
{
    return 3;
}

- (NSInteger)menu:(DOPDropDownMenu *)menu numberOfRowsInColumn:(NSInteger)column
{
    if (0 == column) {
        return self.classifys.count;
    } else if (1 == column) {
        return self.hotel.count;
    } else {
        return self.sorts.count;
    }
}
- (NSString *)menu:(DOPDropDownMenu *)menu titleForRowAtIndexPath:(DOPIndexPath *)indexPath;
{
    if (0 == indexPath.column) {
        return self.classifys[indexPath.row];
    } else if (1 == indexPath.column) {
        return self.area[indexPath.row];
    } else {
        return self.sorts[indexPath.row];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
